package com.czy.seed.mvc.home.mapper;

import com.czy.seed.mvc.home.entity.Merchant;
import com.czy.seed.mybatis.base.mapper.BaseMapper;
import com.czy.seed.mybatis.config.mybatis.annotations.AutoMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


@AutoMapper
public interface MerchantMapper extends BaseMapper<Merchant>{
    @Select("SELECT   DISTINCT   \n" +
            "\tmerchant.ID,\n" +
            "\tmerchant.COMPANY_NAME as companyName,\n" +
            "\tmerchant.TEL,\n" +
            "\tmerchant.MAIL,\n" +
            "\tmerchant.AFFILIATED_REGIONAL as affiliatedRegional,\n" +
            "\tmerchant.INSTITUTION_CODE as institutionCode,\n" +
            "\tmerchant.ID_CARD_NO as idCardNo,\n" +
            "\tmerchant.BUSINESS_MODEL as businessModel,\n" +
            "\tmerchant.TYPE,\n" +
            "\tmerchant.USER_ID as userId,\n" +
            "\tmerchant.CREATION_TIME as creationTime,\n" +
            "\tmerchant.UPDATE_TIME as updateTime,\n" +
            "\tmerchant.VERSION,\n" +
            "\tmerchant.COMPANY_LOGO as companyLogo,\n" +
            "\tmerchant.GOODS_TYPE goodsType,\n" +
            "\tmerchant.OFFICE_ID as officeId \n" +
            "FROM \n" +
            "merchant\n" +
            "left JOIN commodity ON commodity.BUSINESSES_ID = merchant.ID \n" +
            "inner join seed_sys_user on seed_sys_user.id=merchant.USER_ID\n" +
            "WHERE\n" +
            "(merchant.TYPE = '0' or commodity.INSTALL ='2'  or seed_sys_user.ENABLED='0') AND merchant.OFFICE_ID=#{userId}\n")
    List<Merchant> selectMerchant4CreateBy(@Param("userId") long userId);


}
















